home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_riv_elevator.cog < prev    next >
Text File  |  1999-11-15  |  14KB  |  526 lines

  1. # Jones 3D Cog Script
  2. #
  3. # RIV_Elevator.cog
  4. #
  5. # [TRM]
  6. #
  7. # (C) 1999 LucasArts Entertainment Company LLC. All Rights Reserved
  8. #
  9. # ========================================================================================
  10.  
  11. symbols
  12.  
  13.     message     startup
  14.     message     entered
  15.     message     exited
  16.     message     activated
  17.     message     arrived
  18.     message     timer
  19.     message     pulse
  20.  
  21.     thing       player          local
  22.     thing       pushed          local
  23.     thing       pulled          local
  24.     thing       indy_Elevator   local
  25.     
  26.     thing       indy
  27.     thing       lever_Pos
  28.     thing       offsetCam
  29.     thing       elevator_Cam1
  30.     thing       elevator_Cam2
  31.     thing       lever_Look
  32.     thing       cam2_Look
  33.     thing       walkTarg1
  34.     thing       walkTarg2
  35.     
  36.     thing       water_Wheel
  37.     thing       elevator
  38.     thing       wheel_Shaft
  39.     thing       pully
  40.     
  41.     # ** poly line things **
  42.     thing       st_Elevator     # attach to top of elevator
  43.     thing       st_Gear         # gear in elevator base
  44.     thing       end_Pully1      # end for st_Elevator
  45.     thing       end_Pully2      # end for st_Gear
  46.     thing       poly_Rope1      local
  47.     
  48.     sector      start_Amb
  49.     sector      stop_Amb
  50.     
  51.     surface     surf0       linkID=1
  52.     
  53.     template    tplLevPull=pullever         local
  54.     template    tplLevPush=pushlever        local
  55.     template    tpl_Indy=indy_actor         local
  56.     
  57.     keyframe    leverPull=gen_lever_pull.key        local
  58.     keyframe    leverPush=gen_lever_push.key        local
  59.     
  60.     keyframe    indyPull=in_pull_lever.key          local
  61.     keyframe    indyPush=in_push_lever.key          local
  62.     
  63.     sound       sndLever=gen_lever_pull.wav             local
  64.     sound       snd_Shaft=riv_elev_gears_turn.wav       local
  65.     sound       snd_Engage=riv_elev_wheel_engage.wav    local
  66.     sound       snd_Elevator1=riv_elev_stop.wav         local
  67.     sound       snd_Pully=riv_elev_topwheel_turn.wav    local
  68.     sound       snd_Wheel=nub_bull_move2_c.wav          local
  69.     
  70.     # ** rope sfx **
  71.     sound        ambient0=tem_bridge_b.wav   local
  72.     sound        ambient1=tem_bridge_c.wav   local
  73.     
  74.     material    mat_Rope=fhead_rope_sde.mat                local
  75.     #material    mat_Rope=wheel_water_rpsde.mat          local
  76.     
  77.     # ** subroutines **
  78.     flex        pullLever           local
  79.     flex        pushLever           local
  80.     flex        lowerElevator       local
  81.     
  82.     int         onSpot=0            local
  83.     int         lever_Ready=1       local
  84.     int         wheel_Ready=0       local
  85.     int         elevator_Ready=0    local
  86.     int         inElevator=0        local
  87.     int         at_Top=0            local
  88.     int         shaft_Track         local
  89.     int         pully_Track         local
  90.     int         wheel_Track         local
  91.     int         playing=0           local
  92.     
  93. end
  94.  
  95. # ========================================================================================
  96.  
  97. code
  98.  
  99. startup:
  100.  
  101.     pushed = CreateThing(tplLevPull, lever_Pos);
  102.     CaptureThing(pushed);
  103.     
  104.     player = GetLocalPlayerThing();
  105.     
  106.     SetThingLight(water_Wheel, '0.25 0.25 0.35', 0.001, 0.1);
  107.     SetThingLight(wheel_Shaft, '0.25 0.25 0.35', 0.001, 0.1);
  108.     SetThingLight(elevator, '0.25 0.25 0.35', 0.001, 0.1);
  109.     SetThingLight(pushed, '0.25 0.25 0.35', 0.001, 0.1);
  110.     
  111.     # draw ropes start at top
  112.     CreatePolylineThing(end_Pully1, st_Elevator, '0 0 0', mat_Rope, 0.007, 0.007, 0.0);
  113.     CreatePolylineThing(end_Pully2, st_Gear, '0 0 0', mat_Rope, 0.007, 0.007, 0.0);
  114.     
  115.     # draw ropes start at bottom
  116.     poly_Rope1 = CreatePolylineThing(st_Elevator, end_Pully1, '0 0 0', mat_Rope, 0.007, 0.007, 0.0);
  117.     CreatePolylineThing(st_Gear, end_Pully2, '0 0 0', mat_Rope, 0.007, 0.007, 0.0);
  118.     CaptureThing(poly_Rope1);
  119.     
  120.     Sleep(0.1);
  121.     AttachThingToThing(st_Elevator, elevator);
  122.     AttachThingToThing(poly_Rope1, elevator);
  123.     
  124.     SetCollideType(pully, 0);
  125.     SetCollideType(wheel_Shaft, 3);
  126.     
  127.     return;
  128.     
  129. # ========================================================================================
  130.  
  131. entered:
  132.  
  133.     if(GetSenderID() == 1)
  134.     {
  135.         onSpot = 1;
  136.     }
  137.     
  138.     if((GetSenderRef() == start_Amb) && (playing == 0))
  139.     {
  140.         # turn on rope ambient
  141.         SetPulse(2.0);
  142.     }
  143.     
  144.     if(GetSenderRef() == stop_Amb)
  145.     {
  146.         # turn off rope ambient
  147.         SetPulse(0.0);
  148.     }
  149.     
  150.     if((GetSenderRef() == elevator) && (elevator_Ready == 1))
  151.     {
  152.         inElevator = 1;
  153.         elevator_Ready = 0;
  154.         
  155.         # do cutscene stuff
  156.         MakeMeStop();
  157.         StartCutscene(2);
  158.         
  159.         indy_Elevator = CreateThing(tpl_Indy, player);
  160.         CaptureThing(indy_Elevator);
  161.         
  162.         # outfit Indy actor
  163.         CopyPlayerHolsters(player, indy_Elevator);
  164.         
  165.         # switch to elevator_Cam1
  166.         SetCameraFocus(2, elevator_Cam1);
  167.         SetCameraSecondaryFocus(2, indy_Elevator);
  168.         SetCurrentCamera(2);
  169.         SetCameraFOV(90, 0, 0.0);
  170.         
  171.         # show actor hide player
  172.         SetThingFlags(player, 0x80000);
  173.         ClearThingFlags(indy_Elevator, 0x80000);
  174.         
  175.         # get the player out of the way
  176.         TeleportThing(player, walkTarg2);
  177.         
  178.         # walk actor to center of elevator
  179.         AISetCutsceneMode(indy_Elevator);
  180.         AISetMoveSpeed(indy_Elevator, 1.0);
  181.         AISetLookThing(indy_Elevator, walkTarg1);
  182.         AISetMoveThing(indy_Elevator, walkTarg1, 1);
  183.         
  184.         # look up as elevator raises
  185.         AISetLookThing(indy_Elevator, cam2_Look);
  186.         
  187.         # raise elevator
  188.         MoveToFrame(elevator, 1, 8.0);
  189.         PlaySoundLocal(snd_Elevator1, 1.0, 0.0, 0x0, 0);
  190.         
  191.         Sleep(2.0);
  192.         
  193.         # make indy turn 180 degrees
  194.         AISetLookThing(indy_Elevator, walkTarg2);
  195.         
  196.         Sleep(2.0);
  197.         
  198.         # switch to elevator_Cam2
  199.         SetCameraFocus(2, elevator_Cam2);
  200.         SetCameraSecondaryFocus(2, indy_Elevator);      #cam2_Look
  201.         SetCurrentCamera(2);
  202.         SetCameraFOV(90, 0, 0.0);
  203.         
  204.         Sleep(1.0);
  205.         
  206.         # zoom camera out
  207.         MoveToFrame(elevator_Cam2, 1, 2.0);
  208.         
  209.         WaitForStop(elevator);
  210.         
  211.         # play elevator stop sound
  212.         PlaySoundLocal(snd_Elevator1, 1.0, 0.0, 0x0, 0);
  213.         StopSound(pully_Track, 1.0);
  214.         StopThing(pully);
  215.         
  216.         # tell arrived that it's at the top
  217.         at_Top = 1;
  218.         
  219.         Sleep(0.25);
  220.         
  221.         # walk actor out of elevator
  222.         AISetMoveSpeed(indy_Elevator, 1.0);
  223.         AISetLookThing(indy_Elevator, walkTarg2);
  224.         AISetMoveThing(indy_Elevator, walkTarg2, 1);
  225.         
  226.         # move player into position
  227.         CopyOrientAndPos(indy_Elevator, player);
  228.         
  229.         # show player and return controls
  230.         SetThingFlags(indy_Elevator, 0x80000);
  231.         ClearThingFlags(player, 0x80000);
  232.         ClearActorFlags(player, 0x200000);
  233.         
  234.         # return camera to player
  235.         SetCameraPosition(1, GetThingPos(elevator_Cam2));
  236.         SetCurrentCamera(1);
  237.         
  238.         EndCutscene();
  239.         
  240.         # ready camera for next time
  241.         MoveToFrame(elevator_Cam2, 0, 4.0);
  242.         
  243.         Call lowerElevator;
  244.     }
  245.     
  246.     return;
  247.     
  248. # ========================================================================================
  249.  
  250. exited:
  251.  
  252.     if((GetSenderID() == 1) && (GetSourceRef() == player))
  253.     {
  254.         onSpot = 0;
  255.     }
  256.     
  257.     return;
  258.     
  259. # ========================================================================================
  260.  
  261. activated:
  262.  
  263.     if((GetSenderRef() == pushed) && (lever_Ready == 1) && (onSpot == 1))
  264.     {
  265.         lever_Ready = 0;
  266.         Call pullLever;
  267.     }
  268.     
  269.     else if((GetSenderRef() == pulled) && (lever_Ready == 1) && (onSpot == 1))
  270.     {
  271.         lever_Ready = 0;
  272.         Call pushLever;
  273.     }
  274.  
  275.     return;
  276.     
  277. # ========================================================================================
  278.  
  279. pullLever:
  280.  
  281.     # do cutscene stuff
  282.     MakeMeStop();
  283.     StartCutscene(2);
  284.     
  285.     # outfit Indy actor
  286.     CopyPlayerHolsters(player, indy);
  287.     
  288.     # switch to offsetCam
  289.     SetCameraFocus(2, offsetCam);
  290.     SetCameraSecondaryFocus(2, lever_Look);
  291.     SetCurrentCamera(2);
  292.     SetCameraFOV(90, 0, 0.0);
  293.     
  294.     # put away any weapon
  295.     DeselectWeaponWait(player);
  296.     
  297.     # show actor hide player
  298.     SetThingFlags(player, 0x80000);
  299.     ClearThingFlags(indy, 0x80000);
  300.     
  301.     # pull the lever
  302.     PlayKey(pushed, leverPull, 4, 0x14, 0);
  303.     PlayKey(indy, indyPull, 4, 0x12, 0);
  304.     Sleep(0.75);
  305.     PlaySoundLocal(sndLever, 1.0, 0.0, 0x0, 1);
  306.     
  307.     # move water wheel into water
  308.     MoveToFrame(water_Wheel, 2, 1.0);
  309.     PlaySoundLocal(snd_Engage, 1.0, 0.0, 0x0, 0);
  310.     WaitForStop(water_Wheel);
  311.     
  312.     Sleep(0.01);
  313.     
  314.     # spin that bad boy
  315.     Rotate(water_Wheel, -360, 2, 2.0);
  316.     Rotate(wheel_Shaft, 360, 2, 2.0);
  317.     Rotate(pully, 360, 2, 2.0);
  318.     
  319.     # start looping sfx
  320.     shaft_Track = PlaySoundThing(snd_Shaft, wheel_Shaft, 1.0, 5.0, 20.0, 0x0001);
  321.     pully_Track = PlaySoundThing(snd_Pully, pully, 1.0, 5.0, 20.0, 0x0001);
  322.     wheel_Track = PlaySoundThing(snd_Wheel, water_Wheel, 1.0, 8.0, 23.0, 0x0001);
  323.     
  324.     # Destroy old lever and create a new one
  325.     DestroyThing(pushed);
  326.     pulled = CreateThing(tplLevPush, lever_Pos);
  327.     CaptureThing(pulled);
  328.     
  329.     SetThingLight(pulled, '0.25 0.25 0.35', 0.001, 0.1);
  330.     
  331.     # stop any unfinished animations
  332.     ResetThing(indy);
  333.     #ResetThing(player);
  334.     
  335.     Sleep(1.0);
  336.     
  337.     # show player and return controls
  338.     SetThingFlags(indy, 0x80000);
  339.     ClearThingFlags(player, 0x80000);
  340.     ClearActorFlags(player, 0x200000);
  341.     
  342.     # return camera to player
  343.     SetCurrentCamera(1);
  344.     
  345.     EndCutscene();
  346.     
  347.     lever_Ready = 1;
  348.     wheel_Ready = 1;
  349.     elevator_Ready = 1;
  350.     
  351.     SetTimer(10.0);
  352.     
  353.     return;
  354.  
  355. # ========================================================================================
  356.  
  357. pushLever:
  358.  
  359.     # do cutscene stuff
  360.     MakeMeStop();
  361.     StartCutscene(2);
  362.     
  363.     # outfit indy actor
  364.     CopyPlayerHolsters(player, indy);
  365.     
  366.     # switch to offsetCam
  367.     SetCameraFocus(2, offsetCam);
  368.     SetCameraSecondaryFocus(2, lever_Look);
  369.     SetCurrentCamera(2);
  370.     SetCameraFOV(90, 0, 0.0);
  371.     
  372.     # put away any weapon
  373.     DeselectWeaponWait(player);
  374.     
  375.     # show actor hide player
  376.     SetThingFlags(player, 0x80000);
  377.     ClearThingFlags(indy, 0x80000);
  378.     
  379.     # push the lever
  380.     PlayKey(pulled, leverPush, 4, 0x14, 0);
  381.     PlayKey(indy, indyPush, 4, 0x12, 0);
  382.     Sleep(0.85);
  383.     PlaySoundLocal(sndLever, 1.0, 0.0, 0x0, 1);
  384.     
  385.     wheel_Ready = 0;
  386.     
  387.     # stop wheel and shaft
  388.     StopThing(water_Wheel);
  389.     StopThing(wheel_Shaft);
  390.     
  391.     # stop looping sfx
  392.     StopSound(shaft_Track, 1.0);
  393.     StopSound(wheel_Track, 1.0);
  394.     
  395.     Sleep(1.0);
  396.     
  397.     # move water wheel out of water
  398.     MoveToFrame(water_Wheel, 0, 1.0);
  399.     PlaySoundLocal(snd_Engage, 1.0, 0.0, 0x0, 0);
  400.     WaitForStop(water_Wheel);
  401.     
  402.     # lower elevator
  403.     MoveToFrame(elevator, 0, 10.0);
  404.     
  405.     # Destroy old lever and create a new one
  406.     DestroyThing(pulled);
  407.     pushed = CreateThing(tplLevPull, lever_Pos);
  408.     CaptureThing(pushed);
  409.     
  410.     SetThingLight(pushed, '0.25 0.25 0.35', 0.001, 0.1);
  411.     
  412.     # stop any unfinished animations
  413.     ResetThing(indy);
  414.     #ResetThing(player);
  415.     
  416.     Sleep(1.0);
  417.     
  418.     # show player and return controls
  419.     SetThingFlags(indy, 0x80000);
  420.     ClearThingFlags(player, 0x80000);
  421.     ClearActorFlags(player, 0x200000);
  422.     
  423.     # return camera to player
  424.     SetCurrentCamera(1);
  425.     
  426.     EndCutscene();
  427.     
  428.     WaitForStop(elevator);
  429.     lever_Ready = 1;
  430.     elevator_Ready = 0;
  431.     at_Top = 0;
  432.     
  433.     # turn off rope ambient
  434.     SetPulse(0.0);
  435.     
  436.     #SetTimerEx(10.0, 1, 0.0, 0.0);
  437.     
  438.     return;
  439.  
  440. # ========================================================================================
  441.  
  442. lowerElevator:
  443.  
  444.     wheel_Ready = 0;
  445.     
  446.     # stop wheel and shaft
  447.     StopThing(water_Wheel);
  448.     StopThing(wheel_Shaft);
  449.     
  450.     # stop looping sfx
  451.     StopSound(shaft_Track, 1.0);
  452.     StopSound(wheel_Track, 1.0);
  453.     
  454.     Sleep(1.0);
  455.     
  456.     # move water wheel out of water
  457.     MoveToFrame(water_Wheel, 0, 1.0);
  458.     PlaySoundLocal(snd_Engage, 1.0, 0.0, 0x0, 0);
  459.     WaitForStop(water_Wheel);
  460.     
  461.     # lower elevator
  462.     MoveToFrame(elevator, 0, 10.0);
  463.     
  464.     # Destroy old lever and create a new one
  465.     DestroyThing(pulled);
  466.     pushed = CreateThing(tplLevPull, lever_Pos);
  467.     CaptureThing(pushed);
  468.     
  469.     SetThingLight(pushed, '0.25 0.25 0.35', 0.001, 0.1);
  470.     
  471.     WaitForStop(elevator);
  472.     lever_Ready = 1;
  473.     at_Top = 0;
  474.     
  475.     return;
  476.  
  477. # ========================================================================================
  478.  
  479. arrived:
  480.  
  481.     if((GetSenderRef() == water_Wheel) && (wheel_Ready == 1))
  482.     {
  483.         #Print("arrived: water_Wheel");
  484.         Rotate(water_Wheel, -360, 2, 2.0);
  485.     }
  486.     
  487.     if((GetSenderRef() == wheel_Shaft) && (wheel_Ready == 1))
  488.     {
  489.         #Print("arrived: wheel_Shaft");
  490.         Rotate(wheel_Shaft, 360, 2, 2.0);
  491.     }
  492.     
  493.     if((GetSenderRef() == pully) && (at_Top == 0))
  494.     {
  495.         #Print("arrived: pully");
  496.         Rotate(pully, 360, 2, 2.0);
  497.     }
  498.     
  499.     return;
  500.  
  501. # ========================================================================================
  502.  
  503. timer:
  504.  
  505.     if((GetSenderID() == 1) && (inElevator == 0))
  506.     {
  507.         # raise elevator
  508.         MoveToFrame(elevator, 1, 6.0);
  509.     }
  510.  
  511.     return;
  512.  
  513. # ========================================================================================
  514.  
  515. pulse:
  516.  
  517.     PlaySoundThing(ambient0[RandBetween(0, 1)], pully, 1.0, 8.0, 20.0, 0);
  518.     PlaySoundThing(ambient0[RandBetween(0, 1)], elevator, 1.0, 8.0, 20.0, 0);
  519.  
  520.     return;
  521.  
  522. # ========================================================================================
  523.  
  524. end
  525.  
  526.